<template>
	<!-- 药列表 -->
	<view class="" style="padding: 30rpx;">
		<up-table>
				<up-tr>
					<up-th>药品名称</up-th>
					<up-th>数量</up-th>
					<up-th>单价</up-th>
					<up-th>小计</up-th>
				</up-tr>
				<up-tr v-for="(item, index) in table" :key="index">
					<up-td>{{item.durgname}}</up-td>
					<up-td>{{item.durgnum}}</up-td>
					<up-td>{{item.repiceprice}}</up-td>
					<up-td>{{item.repicetotal}}</up-td>
				</up-tr>
			
			</up-table>
			
			<view style="margin-top: 20rpx;">
				<view class="" style="font-weight: 30rpx;font-weight: bold;margin-top: 20rpx;">
					📣 取药温馨提示
				</view>
				<view class="" style="font-size: 30rpx;">
					<view class="content">
						<text class="b">携带证件：</text>
						<text>请务必携带本人有效身份证件（如身份证、医保卡或就诊卡）以及医生开具的处方单（如适用），以便核对信息。</text>
					</view>
					<view class="content">
						<text>核对信息：</text>
						<text>取药时请仔细核对药品名称、数量、用法及注意事项，如有疑问请及时向药师咨询。</text>
					</view>
					<view class="content">
						<text class="b">核对信息：</text>
						<text>如对药品使用方法、剂量、副作用等不清楚，请主动向药师询问，切勿自行用药。</text>
					</view>
					<view class="content">
						<text class="b">保存药品：</text>
						<text>请注意药品的储存条件（如避光、冷藏等），并放在儿童不能接触的地方。</text>
					</view>
					
					<view class="">
						<text class="b">按时服药：</text>
						<text>请按照医嘱定时定量服用药物，避免漏服或误服。</text>
					</view>
				</view>
				
			</view>
			
			
			<view class="confirm" @click="onConfirm">
				确认取药
			</view>
			
	</view>
</template>

<script setup>
import { reactive, ref } from 'vue';
import { onLoad } from "@dcloudio/uni-app";
import { selpepiList, chuku } from "@/api/index.js";

	const table = ref([])
	
	
	onLoad(() => {
		let recipeItem = uni.getStorageSync('recipeItem');
		selpepiList({perid:recipeItem?.reportId,page:1,limit:999}).then(res => {
			console.log("res", res)
			table.value = res.data;
		})
	})
	
	function onConfirm() {
		let recipeItem = uni.getStorageSync('recipeItem');
		chuku({reportId:recipeItem?.reportId}).then(res => {
			console.log("res", res)
			uni.showModal({
				title: '取药',
				content: '确认取药吗',
				success: res=>{
					if(res.confirm) {
						uni.showToast({
							title: '取药成功！'
						})
						
						setTimeout(() => {
							uni.switchTab({
								url:'/view/tabbar/index/index'
							})
						},500)
					}
				}
			})
			
		})
	}
</script>

<style lang="scss">
	@import "../../../uni.scss";
	.content {
		margin-top: 20rpx;
		.b {
			font-weight: bold;
		}
	}
	
	.confirm {
		    position: fixed;
		    bottom: 50rpx;
		    left: 32rpx;
		    right: 32rpx;
		    border-radius: 45rpx;
		    background: $color-main;
		    font-family: Source Han Sans;
		    font-size: 32rpx;
		    color: #FFFFFF;
		    height: 90rpx;
		    line-height: 90rpx;
		    text-align: center;
	}
</style>